package com.sz.common.core.service.role;

/**
 * Function: MembershipType <br>
 * Author: Charles <br>
 * Date: 2017-01-20 14:41:00
 */
public enum MembershipType {
    USER(1), SUPPLIER(2), CUSTOMER(3), ORGANIZATION(4), USER_GROUP(5);

    private int value;

    MembershipType(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        if (value < 1 || value > 5) {
            throw new IllegalArgumentException();
        }
        this.value = value;
    }

    public static MembershipType getMembershipType(int value) {
        for (MembershipType c : MembershipType.values()) {
            if (c.getValue() == value) {
                return c;
            }
        }
        return null;
    }

}
